#include <iostream>
#include <memory>
#include <vector>
//
// Created by lingzhitech on 25-11-5.
//
std::shared_ptr<std::vector<int>> allocateVector() {
    auto p = std::make_shared<std::vector<int>>();
    // std::shared_ptr<std::vector<int>> p; // 错误的写法！如果不为shared_ptr绑定指针，那么它指向nullptr
    return p;
}

void assign_vector(std::shared_ptr<std::vector<int>> p) {
    std::cout << "输入你想要的数字：";
    int i;
    while (std::cin >> i) {
        p->push_back(i);
    }
}

void printVector(std::shared_ptr<std::vector<int>> p) {
    std::cout << "该vector中包含：";
    for (std::vector<int>::const_iterator it = p->begin(); it != p->end(); ++it) {
        std::cout << *it << " ";
    }
    std::cout << std::endl;
}
int main() {
    auto p = allocateVector();
    assign_vector(p);
    printVector(p);
}